package com.jeecms.edu.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSONObject;
import com.jeecms.common.web.ResponseUtils;
import com.jeecms.edu.entity.SchoolInformation;

/**
 *  搜索栏搜索按钮及热门标签 搜索结果保存
 */
@WebServlet("/FullSearch")
public class FullSearch extends HttpServlet {
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String search=request.getParameter("searchs");
//		int num=Integer.parseInt(request.getParameter("page"));
		List searchlist=SchoolInformation.searchKeyInfo(search);
//		System.out.println(searchlist.size()+" List"+searchlist);
		JSONObject jsonObject=new JSONObject();
		if (null!=searchlist && searchlist.size()!=0) {
			request.getSession().getServletContext().setAttribute("schoollist", searchlist);
			request.getSession().getServletContext().setAttribute("exadd", search);
			jsonObject.put("report", "0");
			String json = jsonObject.toJSONString();
			ResponseUtils.renderJson(response, json); 
		}else{
			jsonObject.put("report", "1");
			String json = jsonObject.toJSONString();
			ResponseUtils.renderJson(response, json);
		}
	}
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}
}
